/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.spring66.training.entity;

import java.util.Collection;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author TwinP
 */
@Entity
public class Vet extends Person {

    private Collection<Specialty> specialties;

    /**
     * @return the specialties
     */
    @ManyToMany(cascade = CascadeType.PERSIST)
	@JoinTable(name = "VETS_SPECIALTIES",
			uniqueConstraints = @UniqueConstraint(columnNames = {"vet_id", "name"}),
			joinColumns = @JoinColumn(name = "vet_id", referencedColumnName = "id"),
			inverseJoinColumns = @JoinColumn(name = "name", referencedColumnName = "name")
	)
    @OrderBy("name")
    public Collection<Specialty> getSpecialties() {
        return specialties;
    }

    /**
     * @param specialties the specialties to set
     */
    public void setSpecialties(Collection<Specialty> specialties) {
        this.specialties = specialties;
    }
}
